﻿Namespace TransferEngine

    Friend Class UploadQueue
        Public ReadOnly Node As Framework.Net.Node
        Public ReadOnly NodeId As Integer

        Private mRequests As New Generic.Queue(Of TransmitPartWorkItem)

        Public Sub New(ByVal node As Framework.Net.Node)
            Me.Node = node
            Me.NodeId = node.Buddy.Id
        End Sub

        Public Sub QueueRequest(ByVal request As TransmitPartWorkItem)
            SyncLock mRequests
                mRequests.Enqueue(request)
            End SyncLock
        End Sub
        Public Function GetNext() As TransmitPartWorkItem
            SyncLock mRequests
                If mRequests.Count > 0 Then
                    Return mRequests.Dequeue()
                Else
                    Return Nothing
                End If
            End SyncLock
        End Function

    End Class
End Namespace